<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
		#text{
			width: 200px;
			text-align: center;
		}	
			
			
		</style>
	<script type="text/javascript">
		var flag=false;
		function toggleLight(){
			var img=document.getElementById("light")
			var text=document.getElementById("text")
			if(flag==false){
			img.setAttribute("src","img/on.png")
			text.innerHTML="灯亮了"
			flag=true
			text.setAttribute("style","color:red;")
			}
			else{
				img.setAttribute("src","img/off.png")
				text.innerHTML="灯灭了"
				flag=false
				text.setAttribute("style","color:black;")
				}
			}
		
	</script>
	</head>
	<body>
		<div onclick="toggleLight()">
			<img src="img/off.png"  id="light" width="200px">
			<h1 id="text" >灯灭了</h1>
		</div>
	</body>
</html>
